#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
using namespace std;

int main()
{
  int n;
  cin >> n;
  string s1,s2;
  string last;
  string r;
  while(n--)
  {
  	cin >> s1;
  	cin >> s2;
  	if(s1 == "a" || s1 == "b" || s1 == "c")
  	{
  		if(s1 == "a")
  		{
  			s2+="+";
  			string t;
  			cin >> t;
  			s2+=t;
  		    int ret = stoi(s2)+stoi(t);
  		    s2+="=";
  			s2 += to_string(ret);
  			cout << s2 << endl;
  			cout << s2.size() << endl;
  			last = "+";
		  }
		  else if(s1 == "b")
  		{
  			s2+="-";
  			string t;
  			cin >> t;
  			s2+=t;
  			int ret = stoi(s2)-stoi(t);
  			s2+="=";
  			s2 += to_string(ret);
  			cout << s2 << endl;
  			cout << s2.size() << endl;
  			last = "-";
		  }
		  else if(s1 == "c")
  		{
  			s2+="*";
  			string t;
  			cin >> t;
  			s2+=t;
  			int ret = stoi(s2)*stoi(t);
  			s2+="=";
  			s2 += to_string(ret);
  			cout << s2 << endl;
  			cout << s2.size() << endl;
  			last = "*";
		  }
  	
	  }
	  else
	  {
	  	if(last == "+")
	  	{
	  		int ret = stoi(s1) + stoi(s2);
	  		s1+=last;
	  		s1+=s2;
	  		s1+="=";
	  		s1+=to_string(ret);
	  		cout << s1 << endl;
	  		cout << s1.size() << endl;
	  		
		  }
		  else if(last == "-")
	  	{
	  		int ret = stoi(s1) - stoi(s2);
	  		s1+=last;

	  		s1+=s2;
	  		s1+="=";
	  		s1+=to_string(ret);
	  		cout << s1 << endl;
	  		cout << s1.size() << endl;
	  		
		  }
		else if(last == "*")
	  	{
	  		int ret = stoi(s1) * stoi(s2);
	  		s1+=last;
	  		s1+=s2;
	  		s1+="=";
	  		s1+=to_string(ret);
	  		cout << s1 << endl;
	  		cout << s1.size() << endl;
	  		
		  }
	  }
  }
}
